/*
 * SDL_gfx图片操作
 * 
 * 最后修改: 2006年12月1日星期五
 * 文曦畅
 *
 * 历史:
 */

#include <SDL.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <SDL_image.h>
#include <SDL_rotozoom.h>

#include "base.h"

Image img_adv_rotate(Image src, int angle)
{
	Image ret, tmp;
	tmp = rotozoomSurface(src, (double) angle, 1, 1);
	
	SDL_SetColorKey(tmp, SDL_SRCCOLORKEY, 0);
	ret = SDL_DisplayFormat(tmp);
	SDL_FreeSurface(tmp);
	
	return ret;
}

Image img_adv_zoom(Image src, double xscale, double yscale)
{
	if(xscale < 0) xscale = 0;
	if(yscale < 0) yscale = 0;
	
	Image ret, tmp;
	tmp = zoomSurface(src, xscale, yscale, 1);
	
	SDL_SetColorKey(tmp, SDL_SRCCOLORKEY, 0);
	ret = SDL_DisplayFormat(tmp);
	SDL_FreeSurface(tmp);
	
	return ret;
}

void img_adv_set_alpha(Image img, Uint8 alpha)
{
	SDL_SetAlpha(img, SDL_SRCALPHA, alpha);
}

int img_get_width(Image img)
{
	return (int) img -> w;
}

int img_get_height(Image img)
{
	return (int) img -> h;
}
